package com.cavy.platform.server.controller;

import com.cavy.platform.server.ResultInfo;
import com.cavy.platform.server.dto.ProjectCreateDto;
import com.cavy.platform.server.dto.ProjectDeleteDto;
import com.cavy.platform.server.dto.ProjectDto;
import com.cavy.platform.server.dto.ProjectSearchDto;
import com.cavy.platform.server.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author 唐旭
 * @Date 2018/7/17
 */
@RequestMapping("/workSpace/project")
@RestController
public class ProjectController {
    @Autowired
    private ProjectService service;

    //创建
    @PostMapping("create")
    public ResultInfo create(@RequestBody @Valid ProjectCreateDto dto) {
        service.create(dto);
        return ResultInfo.newSuccess();
    }

    //删除
    @PostMapping("delete")
    public ResultInfo delete(@RequestBody @Valid ProjectDeleteDto dto) {
        service.delete(dto);
        return ResultInfo.newSuccess();
    }

    //列表
    @GetMapping("list")
    public List<ProjectDto> list(ProjectSearchDto dto) {
        return service.list(dto);
    }

}
